<template>
  <BasicModal
    :title="title"
    :width="700"
    v-bind="$attrs"
    @ok="methods.handleSubmit"
    @register="registerModel"
    :useWrapper="true"
    destroyOnClose
  >
    <BasicForm @register="registerForm" />
  </BasicModal>
</template>
<script setup lang="ts">
  import ApiV1 from '@/views/common/operate/ApiV1';
  import BasicForm from '@/components/Form/src/BasicForm.vue';
  import BasicModal from '@/components/Modal/src/BasicModal.vue';
  import { useDeptsUpdateSchemaForm } from '@/api/http/system/senior/depts/depts.data';
  import {
    apiGetDeptsDetailsPath,
    apiPostDeptsAdd,
    apiPostDeptsUpdatePath,
  } from '@/api/http/system/senior/depts/depts.api';

  const emit = defineEmits(['success', 'register']);
  const { registerForm, registerModel, methods, title } = ApiV1.useHandle(emit, {
    formProps: { schemas: useDeptsUpdateSchemaForm() },
    title: '组织机构',
    details: apiGetDeptsDetailsPath,
    saveFn: apiPostDeptsAdd,
    updateFn: apiPostDeptsUpdatePath,
    pkidAlias: 'deptId',
  });
</script>
